﻿using Dapper;
using Estsh.Core.Base;
using Estsh.Core.Model.EnumUtil;
using Estsh.Core.Models;
using Estsh.Core.Services;
using Estsh.Core.Wms.IRepositories;
using Estsh.Core.Wms.IServices;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Estsh.Core.Wms.Services
{
    /// <summary>
    /// 库存查询
    /// </summary>
    public class StockQueryService : BaseService<BaseEntity>, IStockQueryService
    {
        private readonly IStockQueryRepository repository;
        public StockQueryService(IStockQueryRepository _repository) : base(_repository)
        {
            repository = _repository;
        }
        //获取库存查询信息
        public SetObjectDetail GetStockQueryList(string part_spec)
        {

            SetObjectDetail rfInfo = new SetObjectDetail();//返回消息
            List<SysStock> sysStocks = repository.GetStockQueryList(part_spec);

            if (sysStocks.Count > 0)
            {
                rfInfo.type = "PASS";
                rfInfo.message = "零件库存查询成功";
                rfInfo.wmsObjectDetail = sysStocks.ConvertAll(s => (object)s);
            }
            else
            {
                rfInfo.type = "FAIL";
                rfInfo.message = "未查询到数据，请检查！";
            }
            return rfInfo;
        }
    }
}
